<?php
/**
 * Created by PhpStorm.
 * User: qttx
 * Date: 2019/5/30
 * Time: 13:58
 */
namespace app\admin\model;

class AnnouncementModel extends BaseModel
{
    protected $table = "xst_announcement";
    protected $rule = [
        'id' => '',
    ];
    protected $msg = [
        'id' => '',
    ];
    public function index()
    {
        return $this->order('createtime desc')->paginate(10,false,['query'=>request()->param()]);
    }
    public function getOneId($id)
    {
        return $this->where('id',$id)->find();
    }
    public function add()
    {
        $title = request()->post('title');
        $content = request()->post('content');
        return $this->insert([
            'title'=>$title,
            'content'=>$content,
            'createtime'=>time()
        ]);
    }
    public function edit()
    {
        $title = request()->post('title');
        $content = request()->post('content');
        $id = request()->post('id');
        return $this->where('id',$id)->update([
            'title'=>$title,
            'content'=>$content,
            'createtime'=>time()
        ]);
    }
    public function del()
    {
        $id = request()->post('id');
        return $this->where('id',$id)->delete();
    }
    public function dell()
    {
        $id = request()->post('id');
        return $this->where('id','in',$id)->delete();
    }
}